#include <iostream>
#include "Utilities.h"
#include "Ui.h"
#include "History.h"
#include "Job.h"

#define BUILT_INS 2

const char * built_ins[BUILT_INS] =
{
	"vash",
	"exit"
};

int main(int argc,char * argv[])
{
	redirectFd(STDERR_FILENO,getHomePath()+"/.config/vash/log");
	Database db(getHomePath()+"/.config/vash");
	Enviroment env(&db);
	History his(&db);
	Ui ui(&db,&env);
	std::string line;
	SVector data = his.getHistory(History::TimeOrder);
	for( SVector::iterator itr = data.begin() ; itr != data.end() ;itr++ )
		std::cerr << "Value: " << *itr << std::endl;
	data = his.getHistory(History::FreqOrder);
	std::cerr << "Freq:\n\n";
	for( SVector::iterator itr = data.begin() ; itr != data.end() ;itr++ )
		std::cerr << "Value: " << *itr << std::endl;
	while(1)
	{
		line = ui.readLine();
		std::cerr << "Input:\'" << line  << "\'" << std::endl;
		if(line == "exit" || line == "")
			break;
		Job * job = new Job(line);
		
		his.insertToHistory(job);
//		job->release();
	}
	return 0;
}
